<?php
/**
 * Class for generating a PDF file - cover (outside) of the "newspaper"
 *
 * @author mario
 */
class CoverPDF extends TCPDF {

    protected $colwidth = 125;

    public function PrintArticles($txt_left) {
	$this->AddPage('L','A4');
	$this->SetFont('dejavusans', '', 8.5);
	$this->writeHTMLCell($this->colwidth, 0,15,10,$txt_left,0,1,0,false,'J');
    }

    public function PrintFrontPage() {
	$this->writeHTMLCell(0, 0, 195, 80, "<h1>SPRÁVY</h1>");
	$this->writeHTMLCell(0, 0, 175, 90, "<h3><i>\"Je veľmi smutné, že dneska je tak málo užitočných informácií.\"</i></h3>");
	$this->writeHTMLCell(0, 0, 235, 100, "<h4><i>Oscar Wilde</i></h4>");
    }

    public function PrintPage() {
	$this->SetCreator(PDF_CREATOR);
	$this->SetAuthor('web news');
	$this->SetTitle("LETAK 2/2");
	$this->SetSubject('LETAK');
	$this->setPrintHeader(false);
	$this->setPrintFooter(false);
	$this->SetAutoPageBreak(TRUE, 10);

	$articles = Doctrine::getTable('Article')->getArticles();
	$txt_left = "";
	foreach ($articles as $num => $article) {
	    if ($num>3 & $num<6) {
		$txt_left .= "<h1>".$article->getTitle()."</h1>";
		$txt_left .= $article->getContent();
	    }
	}
	$this->PrintArticles($txt_left);
	$this->PrintFrontPage();
    }
    
}

?>
